Timer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A start 0 9 2
1
import prometheus from 'prom-client';
2
3
import objectOnlyKeys from 'utils/object-only-keys';
4
// import objectContains from 'utils/object-contains';
5
6
const { Summary } = prometheus;
7
8
export default class Timer extends Summary {
9
  start(untrimmedLabels = {}) {
10
    const { labelNames } = this;
11
    const labels = objectOnlyKeys(untrimmedLabels, labelNames);
12
    const timerStopper = this.startTimer(labels);
13
    return (dirtyEndLabels = {}) => {
14
      const endLabels = objectOnlyKeys(dirtyEndLabels, labelNames);
15
      timerStopper(endLabels);
16
    };
17
  }
18
}
19